package cn.botter.subject.infra.rpc;

import cn.botter.auth.api.UserFeignService;
import cn.botter.auth.entity.AuthUserDTO;
import cn.botter.auth.entity.Result;
import cn.botter.subject.infra.entity.UserInfo;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @BelongsProject: bo-club
 * @BelongsPackage: cn.botter.subject.infra.rpc
 * @Author: 爱写Bug的Botter
 * @CreateTime: 2025-03-30:16:14
 * @Description: 描述
 * @Version: 1.0
 */
@Component
public class UserRpc {

    @Resource
    private UserFeignService userFeignService;

    public UserInfo getUserInfo(String userName) {
        AuthUserDTO authUserDTO = new AuthUserDTO();
        authUserDTO.setUserName(userName);
        Result<AuthUserDTO> result = userFeignService.getUserInfo(authUserDTO);
        UserInfo userInfo = new UserInfo();
        if (!result.getSuccess()) {
            return userInfo;
        }
        AuthUserDTO data = result.getData();
        userInfo.setUserName(data.getUserName());
        userInfo.setNickName(data.getNickName());
        userInfo.setAvatar(data.getAvatar());
        return userInfo;
    }
}
